package com.jbookshelf.beans;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.FacesConverter;


import org.springframework.stereotype.Component;

import com.jbookshelf.dal.entities.Permissions;

@Component
@FacesConverter(value = "PermissionsConverter")
public class PermissionsConverter implements Converter {


	@Override
	public Object getAsObject(FacesContext arg0, UIComponent arg1, String arg2) {

		Permissions permissions = new Permissions();

		permissions.setId(Integer.parseInt(arg2));

		return permissions;

	}

	@Override
	public String getAsString(FacesContext arg0, UIComponent arg1, Object arg2) {

		return String.valueOf(((Permissions) arg2).getId());
	}
}
